#!/bin/bash

#Script to read 16-bit values from the EEPROM and write them to curve.txt
#in a format gnuplot understands.

#Example gnuplot command to plot the curves of a red, green and blue led:
#plot "curve_red.txt" using 1:2 title "Red" with lines, "curve_green.txt" using 1:2 title "Green" with lines, "curve_blue.txt" using 1:2 title "Blue" with lines

popts="-P /dev/parport0 -c bsd -E vcc"
popts="-c usbasp"
#popts="$popts -i 100"

avrdude $popts -u -p attiny44 -U "eeprom:r:eeprom.out:d"  || exit 1

IFS=','
h='';
n=0;
for x in `cat eeprom.out`; do
#	echo $x;
	if [ -z "$h" ]; then
		h=$x;
	else
		echo $n $(($h*256+$x))
		h=""
	fi
	n=$(($n+2));
done | tee curve.txt

